home *** CD-ROM | disk | FTP | other *** search
/ PsL Monthly 1993 December / PSL Monthly Shareware CD-ROM (December 1993).iso / prgmming / dos / basic / ezmouse.exe / EZMOUSE.BAS < prev    next >
Encoding:
BASIC Source File  |  1991-12-25  |  3.1 KB  |  79 lines

  1. '╔═══════════════════════════════════════════════════════════════════╗
  2. '║                         EZMOUSE DEMO                              ║
  3. '║                     Written by FRED SEXTON Jr.                    ║
  4. '║                  Hereby released to public domain                 ║
  5. '╠═══════════════════════════════════════════════════════════════════╣
  6. '║ The COMMON SHARED variables are required for these routines.      ║
  7. '║ The order of the COMMON SHARED variables MUST BE EXACTLY AS SHOWN.║
  8. '╠═══════════════════════════════════════════════════════════════════╣
  9. '║     lft = left mouse button status                                ║
  10. '║         0 = left button is not pressed                            ║
  11. '║         1 = left button is pressed                                ║
  12. '║     lftcc = left mouse button click count                         ║
  13. '║             if this value = 2 then a double click occurred        ║
  14. '║     rgt = right mouse button status                               ║
  15. '║         0 = right button is not pressed                           ║
  16. '║         1 = right button is pressed                               ║
  17. '║     rgtcc = right mouse button click count                        ║
  18. '║             if this value = 2 then a double click occurred        ║
  19. '║     mx = mouse pointer x axis location                            ║
  20. '║     my = mouse pointer y axis location                            ║
  21. '╚═══════════════════════════════════════════════════════════════════╝
  22. DEFINT A-Z
  23. '$DYNAMIC
  24. COMMON SHARED lft, lftcc, rgt, rgtcc, mx, my     'set up the variables
  25.  
  26. SCREEN 7                                         'set graphics mode
  27.                                                  'in this mode mx will be
  28.                                                  '0-638 so divide by 2
  29.                                                  'for screen coordinate
  30.  
  31. CALL mreset(found)                               'check for mouse
  32. IF found <> 1 THEN END                           'and reset it's defaults
  33.  
  34. CALL hookmouse(lft)                              'hook variables to mouse
  35.  
  36. LINE (0, 0)-(319, 199), 4, BF
  37. LINE (10, 10)-(309, 189), 14, B                  'setup screen for demo
  38. LINE (11, 11)-(308, 188), 1, BF
  39.  
  40. minx = 22: maxx = 616                            'multiply x-coordinates by 2
  41. miny = 11: maxy = 188
  42. CALL msetlim(minx, maxx, miny, maxy)             'set min/max mouse values
  43.  
  44. COLOR 15, 4
  45. LOCATE 25, 13
  46. PRINT "<ESC> TO EXIT";
  47. LOCATE 1, 1
  48. PRINT "X=     Y="
  49.  
  50. CALL mcuron                                      'turn on mouse cursor
  51.  
  52. DO
  53.   LOCATE 1, 3
  54.   PRINT USING "###"; mx \ 2
  55.   LOCATE 1, 10
  56.   PRINT USING "###"; my
  57.   LOCATE 1, 14
  58.   IF lft THEN
  59.    PRINT "LEFT";
  60.    IF lftcc > 1 THEN PRINT " DOUBLE";  ELSE PRINT "       ";
  61.   ELSE
  62.    PRINT "           "
  63.   END IF
  64.   LOCATE 1, 26
  65.   IF rgt THEN
  66.    PRINT "RIGHT";
  67.    IF rgtcc > 1 THEN PRINT " DOUBLE";  ELSE PRINT "       ";
  68.   ELSE
  69.    PRINT "            "
  70.   END IF
  71. LOOP WHILE INKEY$ <> CHR$(27)
  72.  
  73. CALL mcuroff                                     'turn off mouse cursor
  74.  
  75. CALL unhookmouse                                 'MUST UNHOOK MOUSE
  76.  
  77. END
  78.  
  79.